s = input()
sk = ''
flag = True
for skobka in s:
    if skobka in "([{<":
        sk += skobka
    elif skobka in ")]}>":
        last = sk[-1]
    if skobka == ")" and last == "(":
        sk = sk[:-1]
    elif skobka == "]" and last == "[":
        sk = sk[:-1]
    elif skobka == "}" and last == "{":
        sk = sk[:-1]
    elif skobka == ">" and last == "<":
        sk = sk[:-1]
if sk == '':
    print("YES")
else:
    print("NO")